use strict;
use warnings;
   
#if any parameter is passed then dump out accumulated data
# else just the nu,berof hits at each cutoff

my $acc;
my $temp = shift;
if(defined($temp)){
  if($temp eq "acc"){
    $acc = $temp
  }
  else{
    die "only acc allowed to set to dump acummulated passes\n";
  }
}


my  @q_bin;
my  @t_bin;
my  @m_bin;

for(my $i=0;$i<=100; $i++){
  $q_bin[$i] = 0;
  $t_bin[$i] = 0;
  $m_bin[$i] = 0;
}

# percentage_vals
while(<>){
  my ($q,$t,$acc) = split;

  $q_bin[$q]++;
  $t_bin[$t]++;
  if($q>$t){
    $m_bin[$q]++;
  }
  else{
    $m_bin[$t]++;
  }
}
if(!defined($acc)){
  for(my $i=0;$i<=100; $i++){
    print $i.",".$q_bin[$i].",".$t_bin[$i].",".$m_bin[$i]."\n";
  }
  exit;
}


my $q_accum=0;
my $t_accum=0;
my $m_accum=0;

for(my $i=100;$i>=0;$i--){
  $q_accum+=$q_bin[$i];
  $t_accum+=$t_bin[$i];
  $m_accum+=$m_bin[$i];
  
  print "$i,$q_accum,$t_accum,$m_accum\n";
}


